<?php
//
// +------------------------------------------------------------------------+
// | PHP Version 5.4                                                        |
// +------------------------------------------------------------------------+
// | Copyright (c) All rights reserved.                                     |
// +------------------------------------------------------------------------+
// | 世纪车来车往(北京）网络科技有限公司 版权所有！                               |
// | TEL:010-63732365  HOTLINE:400-6688-365  EMAIL:clcw@clcw.com.cn         |
// | $Revision: 1.0 $                                                       |
// +------------------------------------------------------------------------+
// | Author: xiangminghu@clcw.com.cn                                        |
// +------------------------------------------------------------------------+
//

namespace AuctionBack\Logic;


class ActivitySupermanCodeLogic extends BaseLogic
{
    protected $autoCheckFields = false;

    protected $activitySupermanCodeModel;

    public function _initialize()
    {
        $this->activitySupermanCodeModel = D('ActivitySupermanCode', 'Model');
    }

    /**
     * 待发放卡券
     *
     * @param       $page
     * @param       $pageSize
     * @param array $params
     *
     * @return array
     */
    public function getCodeList($page, $pageSize, $params = [])
    {
        $page = $page < 1 ? 1 : (int)$page;
        $pageSize = $pageSize < 1 ? 10 : (int)$pageSize;
        $map = [];
        $map['is_send'] = ['eq', 0];
        if ($params['code']) {
            $map['act_code'] = ['eq', $params['code']];
        }
        $total = $this->activitySupermanCodeModel->where($map)->count();
        $list = $this->activitySupermanCodeModel->where($map)
            ->page($page, $pageSize)
            ->select();

        return [
            'total' => $total,
            'list'  => $list
        ];
    }
}